package com.hqyj.module.StaffManage.controller;

import com.github.pagehelper.PageInfo;
import com.hqyj.module.StaffManage.entity.Dept;
import com.hqyj.module.StaffManage.entity.MyPage;
import com.hqyj.module.StaffManage.entity.Staff;
import com.hqyj.module.StaffManage.service.StaffManageService;
import com.hqyj.module.clock.pojo.SearchBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @Description：StaffManageController
 * @Author ：Cwd
 * @Date ：2021/10/8 20:19
 */
@RestController
@RequestMapping("/staff")
public class StaffManageController {

    @Autowired
    StaffManageService staffManageService;

    /**
     * http://127.0.0.1:8086/staff/add?
     */
    @ResponseBody
    @PostMapping(value = "/add",consumes = "application/json;charset=utf-8")
    public HashMap<String, Object> insertStaff(@RequestBody Staff staff){
        return staffManageService.add(staff);
    }

    /**
     * http://localhost:8086/staff/update?
     */
    @ResponseBody
    @PostMapping(value = "/update",consumes = "application/json;charset=utf-8")
    public HashMap<String, Object> update(@RequestBody Staff staff) {
        return staffManageService.update(staff);
    }

    /**
     * http://localhost:8086/staff/list
     * {"currentPage":1,"pageSize":5,"orderBy":"user_id","direction":"desc","keyword":""}
     */
    @GetMapping(value = "/list")
    public PageInfo<Staff> list(SearchBean searchBean) {
        System.out.println(searchBean.getKeyword());
        return staffManageService.list(searchBean);
    }

    /**
     * http://127.0.0.1:8086/staff/insertDept?
     */
    @ResponseBody
    @PostMapping(value = "/insertDept",consumes = "application/json;charset=utf-8")
    public HashMap<String, Object> insertDept(@RequestBody Dept dept){
        return staffManageService.insertDept(dept);
    }

    /**
     * http://localhost:8086/staff/updateDept?
     */
    @ResponseBody
    @PostMapping(value = "/updateDept",consumes = "application/json;charset=utf-8")
    public HashMap<String, Object> updateDept(@RequestBody Dept dept) {
        return staffManageService.updateDept(dept);
    }

    /**
     * http://localhost:8086/staff/listDept
     * {"currentPage":1,"pageSize":5,"orderBy":"user_id","direction":"desc","keyword":""}
     */
    @GetMapping(value = "/listDept")
    public PageInfo<Dept> listDept(SearchBean searchBean){
        return staffManageService.listDept(searchBean);
    }
}
